Skip to content

Conversation

@ondrejmirtes
Copy link
Member

Document every method on the Type interface with descriptions of purpose,
behavior, parameters, return values, and usage guidance. Key additions:

  • Interface-level doc explaining the central role of Type and the
    critical rule to never use instanceof for type checks
  • Core methods: isSuperTypeOf, accepts, equals, describe with examples
  • Class identification: getReferencedClasses vs getObjectClassNames vs
    getObjectClassReflections, getClassStringObjectType
  • Member access: canAccessProperties/canCallMethods/canAccessConstants
    and has*/get*/getUnresolved* patterns
  • Array operations: all 13 array transformation methods (chunk, flip,
    pop, shift, slice, splice, reverse, search, shuffle, etc.)
  • Offset access: isOffsetAccessible vs isOffsetAccessLegal,
    setOffsetValueType vs setExistingOffsetValueType
  • Type checking: all is* methods for scalars, strings, and arrays
  • Type conversion: all to* methods (toBoolean through toCoercedArgumentType)
  • Comparison: looseCompare, isSmallerThan, getSmallerType family
  • Templates: inferTemplateTypes, getReferencedTemplateTypes, traverse
  • Other: generalize, tryRemove, getFiniteTypes, hasTemplateOrLateResolvableType

https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437

Document every method on the Type interface with descriptions of purpose,
behavior, parameters, return values, and usage guidance. Key additions:

- Interface-level doc explaining the central role of Type and the
  critical rule to never use instanceof for type checks
- Core methods: isSuperTypeOf, accepts, equals, describe with examples
- Class identification: getReferencedClasses vs getObjectClassNames vs
  getObjectClassReflections, getClassStringObjectType
- Member access: canAccessProperties/canCallMethods/canAccessConstants
  and has*/get*/getUnresolved* patterns
- Array operations: all 13 array transformation methods (chunk, flip,
  pop, shift, slice, splice, reverse, search, shuffle, etc.)
- Offset access: isOffsetAccessible vs isOffsetAccessLegal,
  setOffsetValueType vs setExistingOffsetValueType
- Type checking: all is* methods for scalars, strings, and arrays
- Type conversion: all to* methods (toBoolean through toCoercedArgumentType)
- Comparison: looseCompare, isSmallerThan, getSmallerType family
- Templates: inferTemplateTypes, getReferencedTemplateTypes, traverse
- Other: generalize, tryRemove, getFiniteTypes, hasTemplateOrLateResolvableType

https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
Document every method on the Scope interface, ClassMemberAccessAnswerer
interface, and NamespaceAnswerer interface with descriptions of purpose,
behavior, parameters, return values, and usage guidance.

Scope interface:
- Interface-level doc explaining Scope as the analysis state at an AST
  position, listing all extension types that receive it as a parameter
- File/context methods: getFile vs getFileDescription (trait handling),
  isDeclareStrictTypes, isInTrait/getTraitReflection
- Function context: getFunction, getFunctionName, getParentScope
- Variable tracking: hasVariableType, getVariableType,
  canAnyVariableExist (extract() handling), getDefinedVariables vs
  getMaybeDefinedVariables
- Type resolution: getType (the core method), getNativeType (PHPDoc-free),
  getKeepVoidType (preserves void), getScopeType vs getType (deferred
  evaluation), getScopeNativeType
- Name resolution: resolveName (self/static/parent handling),
  resolveTypeByName (preserves LSB via StaticType/ThisType)
- Reflection helpers: getInstancePropertyReflection,
  getStaticPropertyReflection, getMethodReflection, getConstantReflection
- Scope filtering: filterByTruthyValue/filterByFalseyValue for type
  narrowing in conditional branches
- Context queries: isInClassExists, isInFunctionExists, isInClosureBind,
  isInAnonymousFunction, isInExpressionAssign, isUndefinedExpressionAllowed,
  isInFirstLevelStatement, getFunctionCallStack

ClassMemberAccessAnswerer interface:
- Interface-level doc explaining its role as visibility checker passed
  to Type methods for enforcing public/protected/private access
- canReadProperty vs canWriteProperty (PHP 8.4 asymmetric visibility)
- canCallMethod, canAccessConstant

NamespaceAnswerer interface:
- Interface-level doc explaining namespace resolution context

https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
…pe and Scope interfaces

Document all interfaces and classes reachable through parameter types and return
types of the previously documented Type and Scope interfaces. This covers 31 files
across the type system, reflection layer, and supporting infrastructure:

- Core result types: TrinaryLogic, AcceptsResult, IsSuperTypeOfResult
- Type system: VerbosityLevel, GeneralizePrecision, ConstantScalarType, TypeWithClassName
- Reflection: ClassMemberReflection, PropertyReflection, ExtendedPropertyReflection,
  MethodReflection, ExtendedMethodReflection, FunctionReflection, ParameterReflection,
  ClassConstantReflection, ConstantReflection, ParametersAcceptor,
  ExtendedParametersAcceptor, PassedByReference, Assertions, AttributeReflection
- Callables: CallableParametersAcceptor, SimpleThrowPoint, SimpleImpurePoint
- Generics: TemplateTypeMap, TemplateTypeReference, TemplateTypeVariance
- Prototype resolution: UnresolvedPropertyPrototypeReflection, UnresolvedMethodPrototypeReflection
- PHP version: PhpVersion, PhpVersions

https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
Based on git blame analysis of Type.php, document the recurring pattern
of adding new methods to the Type interface as a bug fix strategy instead
of scattering instanceof checks or utility calls across the codebase.

https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
…ype interfaces

CompoundType: Document the double-dispatch protocol for bidirectional type
comparison, explaining why instanceof CompoundType is the correct pattern
(unlike instanceof SomeSpecificType which is discouraged). Document all
four methods with their decomposition semantics.

AccessoryType: Document the marker interface's role as a refinement type
that always lives inside an IntersectionType alongside a base type. Include
a complete mapping table of all 13 implementations to their corresponding
query methods on the Type interface.

https://claude.ai/code/session_01Htkqstd1mz1dbevHT6Y437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants